Index Property (Attachment Object) 

The Index property returns the index number for the Attachment object within the Attachments collection. Read-only.

Syntax

objAttachment.Index

Data Type

Long

Remarks

The Index property indicates the attachment s position within the parent Attachments collection.

An index value should not be considered to be a static value that remains constant for the duration of a session. The index can change whenever an update occurs to a parent object, such as the message or folder.

Example

Function Attachments_GetByIndex()

Dim lIndex As Long

Dim objOneAttach As Object  ' assume valid attachment

    ' set error handler here

    If objAttachColl Is Nothing Then

        MsgBox "must select an Attachments collection"

        Exit Function

    End If

    If 0 = objAttachColl.Count Then

        MsgBox "must select collection with 1 or more attachments"

        Exit Function

    End If

    ' prompt user for index; for now, use 1

    Set objOneAttach = objAttachColl.Item(1)

    MsgBox "Selected attachment 1: " & objOneAttach.Name

    lIndex = objOneAttach.Index  ' save index to retrieve this later

    ' ...get same attachment object later

    Set objOneAttach = objAttachColl.Item(lIndex)

    If objOneAttach Is Nothing Then

        MsgBox "Error, could not reselect the attachment"

    Else

        MsgBox "Reselected attachment " & lIndex & _

            " using index: " & objOneAttach.Name

    End If

    Exit Function

 

See Also

Attachments Collection2XOH1D, Item Property (Attachments Collection)7ASD49